﻿using MediatR;
using SheepStorage.API.Application.Command.PendingPromptCommand;
using SheepStorage.API.Application.Command.SheepMomPergnantCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.PendingPromptCommandHandler
{
    public class PendingPromptShowCommandHandler : IRequestHandler<PendingPromptShowCommand, Results<List<PromptModel>>>
    {
        private readonly IPendingPromptService pendingPrompt;
        public PendingPromptShowCommandHandler(IPendingPromptService pendingPrompt)
        {
            this.pendingPrompt = pendingPrompt;
        }
        public async Task<Results<List<PromptModel>>> Handle(PendingPromptShowCommand request, CancellationToken cancellationToken)
        {
            var entity = await pendingPrompt.GetPromptModel(request.PromptType);
            if (entity == null)
            {
                return Results<List<PromptModel>>.FailResult();
            }
            return Results<List<PromptModel>>.DataResult(entity);
        }
    }
}
 